import 'package:sqflite/sqflite.dart';
import 'package:xiaofanshu_flutter/utils/db_util.dart';

class AttentionMessageMapper {
  // 插入关注消息
  static Future<int> insert(Map<String, dynamic> data) async {
    Database db = await DBManager.instance.database;
    return await db.insert('attention_message', data);
  }

  // 查询所有关注消息
  static Future<List<Map<String, dynamic>>> queryAll() async {
    Database db = await DBManager.instance.database;
    return await db.query('attention_message', orderBy: 'id DESC');
  }

  // 删除关注消息
  static Future<int> delete(int id) async {
    Database db = await DBManager.instance.database;
    return await db.delete('attention_message', where: 'id = ?', whereArgs: [id]);
  }

  // 清空所有关注消息
  static Future<int> clearAll() async {
    Database db = await DBManager.instance.database;
    return await db.delete('attention_message');
  }
}